package com.example.demo;

import com.example.context.Context;
import com.yomahub.liteflow.core.FlowExecutor;
import com.yomahub.liteflow.flow.LiteflowResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 类说明:
 *
 * @author yangzr
 * @since 2024/7/16 9:53
 */
@RestController
@RequestMapping("test")
@Slf4j
public class DemoController {
    private final FlowExecutor flowExecutor;

    public DemoController(FlowExecutor flowExecutor) {
        this.flowExecutor = flowExecutor;
    }

    @GetMapping("test2")
    public String test2(){
        Context context = new Context();
        context.setA("aaaa");
        context.setB("bbbb");
        LiteflowResponse response = flowExecutor.execute2Resp("chain1","aaaa", context);
        if(!response.isSuccess()){
            log.error(response.getCause().getMessage());
            response.getCause().printStackTrace();
        }
        return "a";
    }
}
